//
//  SchoolStudentTableViewCell.m
//  Civacrm
//
//  Created by mubei on 17/2/16.
//  Copyright © 2017年 王桂敏. All rights reserved.
//

#import "SchoolStudentTableViewCell.h"
#import "GetStudentInfoModel.h"
#import "GetTeacherInfoModel.h"
@implementation SchoolStudentTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
        
        
    }
    return self;
    
}

- (void)createView{
    self.nameLable = [[UILabel alloc] init];
    self.nameLable.font = [UIFont fontWithName:@"Helvetica-Bold" size:((32 / 2) / kScreenHeight6) * kScreenHeight];
    self.nameLable.textColor = ColorWithHexString(@"4e778f");
    [self addSubview:self.nameLable];
    
    self.sexImageView = [[UIImageView alloc] init];
    [self addSubview:self.sexImageView];
    
    self.isAactivateImageView = [[UIImageView alloc] init];
    [self addSubview:self.isAactivateImageView];
    
    self.phoneLable = [[UILabel alloc] init];
    self.phoneLable.font = font(24);
    self.phoneLable.textColor = ColorWithHexString(@"a0c0d2");

    [self addSubview:self.phoneLable];
    
    self.lowLable = [[UILabel alloc]init];
    self.lowLable.backgroundColor = ColorWithHexString(@"f2f8fa");
    [self addSubview:self.lowLable];
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.nameLable.frame = CGRectMake(w(20), h(24), 0, 0);
    [self.nameLable sizeToFit];
    self.sexImageView.frame = CGRectMake(getMaxX(self.nameLable) + w(10), 0, w(20), h(20));
    self.sexImageView.centerY = self.nameLable.centerY;
    self.isAactivateImageView.frame = CGRectMake(getMaxX(self.sexImageView) + w(20), 0, w(70), h(29));
    self.isAactivateImageView.centerY = self.nameLable.centerY;
    self.phoneLable.frame = CGRectMake(w(20), getMaxY(self.nameLable) + h(20), 0, 0);
    [self.phoneLable sizeToFit];
    self.lowLable.frame = CGRectMake(w(20), 0, self.width - w(20), h(2));
}
- (void)setGetStudentInfoModel:(GetStudentInfoModel *)getStudentInfoModel{
    if (self.getStudentInfoModel != getStudentInfoModel) {
        _getStudentInfoModel = getStudentInfoModel;
    }
    self.nameLable.text = getStudentInfoModel.stuname;
//    [self.nameLable sizeToFit];
    if ([getStudentInfoModel.sex isEqualToString:@"男"]) {
        self.sexImageView.image = Image(@"icon_male");
    }else{
        self.sexImageView.image = Image(@"icon_female");
    }
    if ([getStudentInfoModel.isAactivate isEqualToString:@"已激活"]) {
        self.isAactivateImageView.image = Image(@"icon_activate_pre");
    }else{
        self.isAactivateImageView.image = Image(@"icon_activate");

    }
    self.phoneLable.text = getStudentInfoModel.tel;
}
- (void)setGetTeacherInfoModel:(GetTeacherInfoModel *)getTeacherInfoModel{
    if (self.getTeacherInfoModel != getTeacherInfoModel) {
        _getTeacherInfoModel = getTeacherInfoModel;
    }
    self.nameLable.text = getTeacherInfoModel.tname;
    //    [self.nameLable sizeToFit];
    if ([getTeacherInfoModel.sex isEqualToString:@"男"]) {
        self.sexImageView.image = Image(@"icon_male");
    }else{
        self.sexImageView.image = Image(@"icon_female");
    }
    if ([getTeacherInfoModel.isAactivate isEqualToString:@"已激活"]) {
        self.isAactivateImageView.image = Image(@"icon_activate_pre");
    }else{
        self.isAactivateImageView.image = Image(@"icon_activate");
        
    }
    self.phoneLable.text = getTeacherInfoModel.tel;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
